Getting in and out going links from an object?

Hi,

i try to get all incoming and out going links from an object.

I looking for something like this

Link l 
Object o 
Module m = current 

for o in m do
{
    for l in o->"*" do
    {
        //something like
        //print l."i come from"
        //print l."i go to"
        //print l."i'm on this object" 
    }
}

I don't want to use the "LinkModuleDescriptor" because it's not for an full folder but for only one module (current)

With the LMD it looks like that (snippet)

Folder f = folder folder_path
LinkModuleDescriptor lmd 

for lmd in f do
{
    print "Link: "getSourceName(lmd) "->" 
    print getTargetName(lmd) "\n"
    print "Linkmodule: "getName(lmd) "\n"
}

 


meinhana - Fri Feb 05 03:38:50 EST 2016

Re: Getting in and out going links from an object?
Mike.Scharnow - Fri Feb 05 07:08:45 EST 2016

In this post Mathias has posted a scriptlet on how to iterate correctly and version safe over the links of a module:

https://www.ibm.com/developerworks/community/forums/html/topic?id=654cc6f2-e8bd-4602-89d4-3f6ec8021c2a

Hope this helps, regards,Mike

Re: Getting in and out going links from an object?
Mike.Scharnow - Fri Feb 05 07:11:00 EST 2016

LMDs are only about the definition, which links may be created in the future. They tell you nothing about existing links.

Re: Getting in and out going links from an object?
meinhana - Fri Feb 05 07:27:25 EST 2016

Mike.Scharnow - Fri Feb 05 07:08:45 EST 2016

In this post Mathias has posted a scriptlet on how to iterate correctly and version safe over the links of a module:

https://www.ibm.com/developerworks/community/forums/html/topic?id=654cc6f2-e8bd-4602-89d4-3f6ec8021c2a

Hope this helps, regards,Mike

Hi,

Thanks for your answer

but i want to know - how can i get the information of the links.

Information like sourcename and targetname... Where the link comes from and where it ends...

I tried this with the lmd and with that i get these information, but i want to find the same information with link or is that not possible?

 

 

Re: Getting in and out going links from an object?
Mike.Scharnow - Fri Feb 05 08:55:22 EST 2016

meinhana - Fri Feb 05 07:27:25 EST 2016

Hi,

Thanks for your answer

but i want to know - how can i get the information of the links.

Information like sourcename and targetname... Where the link comes from and where it ends...

I tried this with the lmd and with that i get these information, but i want to find the same information with link or is that not possible?

 

 

A link connects objects - for each link there is a source and a target - objects belong to a module, which have a fullName.

So, if you take e.g. the following part of the script:

// Outlinks can be iterated, since the source is already loaded
  for lnk in all o ->"*" do
  {
    // load target
    ModuleVersion mvTarget = targetVersion lnk

 

​you can write in the next line

string sTargetModule = fullName (mvTarget)

The same for In-Links.

After the part

// load source modules of in-link references
  LinkRef lr;
  for lr in all (o<-"*") do {
    ModuleVersion mvSource = sourceVersion lr
         

you can write

string sSourceModule = fullName (mvSource)

 

Re: Getting in and out going links from an object?
meinhana - Fri Feb 05 09:00:54 EST 2016

Mike.Scharnow - Fri Feb 05 08:55:22 EST 2016

A link connects objects - for each link there is a source and a target - objects belong to a module, which have a fullName.

So, if you take e.g. the following part of the script:

// Outlinks can be iterated, since the source is already loaded
  for lnk in all o ->"*" do
  {
    // load target
    ModuleVersion mvTarget = targetVersion lnk

 

​you can write in the next line

string sTargetModule = fullName (mvTarget)

The same for In-Links.

After the part

// load source modules of in-link references
  LinkRef lr;
  for lr in all (o<-"*") do {
    ModuleVersion mvSource = sourceVersion lr
         

you can write

string sSourceModule = fullName (mvSource)

 

Thank you very much!